<?php
/******************************************
 * Author: <YOUR NAME HERE>
 * Description: <YOUR DESCRIPTION HERE>
 ******************************************/
class Categs_smetki extends CustomSecurity { 


	function Categs_smetki($db){ 
    }

	/***********************************
 	 * Add:         Allows the insertion of values into the Table.
 	 * Parameters:  $id, $category
 	 * Return:      (Boolean) True - Successfully Inserted | False - Error
 	 ************************************/
	function add($category){ 

		//Custom SQL Injection Escaping HERE

		$statement = "INSERT INTO categs_smetki (category) VALUES ('$category');";
		$results   = mysql_query($statement);

		if($results){
			return true;
		}else{
			return false;
		}

	}//End add()


	/***********************************
 	 * Remove:      Allows for the removal of record from the database.
 	 * Parameters:  (String)Primary Key Column Name | (Int) Primary Key Value
 	 * Return:      (Boolean) True - Successfully Removed | False - Error
 	 ************************************/
	function remove($primaryKeyValue){ 

		escape_string($primaryKeyValue);

		$statement = "DELETE FROM categs_smetki WHERE id = '$primaryKeyValue'";
		$results   = mysql_query($statement);
		if($results){
			return true;
		}else{
			return false;
		}

	}//End remove()


	/***********************************
 	 * Update:      Allows for the update of a record from the database.
 	 * Parameters:  (String)Primary Key Column Name | (Int) Primary Key Value | (String) Column Name To Update | (String) New Value
 	 * Return:      (Boolean) True - Successfully Updated | False - Error
 	 ************************************/
	function update($primaryKeyValue, $columnNameToUpdate, $columnValue){ 

		escape_string($primaryKeyValue);
		escape_string($columnNameToUpdate);
		escape_string($columnValue);

		$statement = "UPDATE categs_smetki SET $columnNameToUpdate = '$columnValue' WHERE id = '$primaryKeyValue'";
		$results   = mysql_query($statement);
		if($results){
			return true;
		}else{
			return false;
		}

	}//End update()


	/***********************************
 	 * GetAll:       Returns all the records in the database.
 	 * Parameters:   NA
 	 * Return:      (MultiDimensional-Array)String
 	 ************************************/
	function getAll(){ 

		//Custom SQL Injection Escaping HERE

		$statement = "SELECT id, category FROM categs_smetki";
		$mresults   = mysql_query($statement);
		
		$tokens[0] = 'id';
		$tokens[1] = 'category';
		
		return transformResults($mresults, $tokens);

	}//End getAll()


	/***********************************
 	 * GetObject:   Returns a specific record form the batabase.
 	 * Parameters:  (Int) Primary Key Value
 	 * Return:      (Array)String
 	 ************************************/
	function getObject($primaryKeyValue){ 

		escape_string($primaryKeyValue);
		
		$statement = "SELECT id, category FROM categs_smetki WHERE id = '".$primaryKeyValue."'";
		$mresults   = mysql_query($statement);

		$tokens[0] = 'id';
		$tokens[1] = 'category';
		
		return transformResults($mresults, $tokens);

	}//End getObject()


}//End Class Categs_smetki
?>